package org.kzwl.service.web.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.utils.PagingCondition;
import org.kzwl.entity.web.CuHeritageCategory;
import org.kzwl.entity.web.CuVolunteersCategory;
import org.kzwl.mapper.web.CuVolunteersCategoryMapper;
import org.kzwl.service.web.CuVolunteersCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-12-17
 */
@Service
public class CuVolunteersCategoryServiceImpl extends ServiceImpl<CuVolunteersCategoryMapper, CuVolunteersCategory> implements CuVolunteersCategoryService {

    @Override
    public ResponseData<List<CuVolunteersCategory>> queryList() {
        return new ResponseData<>(this.list());
    }


    @Override
    public ResponseData<IPage<CuVolunteersCategory>> queryPage(PagingCondition pagingCondition) {
        return new ResponseData<>(this.baseMapper.selectPage(new Page<>(pagingCondition.getCurrent(),pagingCondition.getSize()),null));
    }

    @Override
    public ResponseData<Void> saveOne(CuVolunteersCategory cuHeritageCategory) {
        this.baseMapper.insert(cuHeritageCategory);
        return new ResponseData<>();
    }

    @Override
    public ResponseData<Void> updateOne(CuVolunteersCategory cuHeritageCategory) {
        this.baseMapper.updateById(cuHeritageCategory);
        return new ResponseData<>();
    }

    @Override
    public ResponseData<CuVolunteersCategory> queryOne(Long Id) {
        return new ResponseData<>(this.baseMapper.selectById(Id));
    }

    @Override
    public ResponseData<Void> deleteId(Long Id) {
        this.baseMapper.deleteById(Id);
        return new ResponseData<>();
    }
}
